﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace appServices
{
    class Mailing
    {
        private MailMessage email = null;

        public Mailing()
        {
            email = new MailMessage();
        }

        public Mailing(string pTo, string pFrom, string pSubject, string pBody)
        {
            email = new MailMessage(pFrom, pTo, pSubject, pBody);
            email.IsBodyHtml = true;
            email.Priority = MailPriority.High;
        }

        public string send()
        {
            string state = string.Empty;
            SmtpClient SMTPServer = new SmtpClient("smtp-out.adista.fr",25);
            try
            {
                SMTPServer.Send(email);
                state = "Mail bien envoyé";
            }
            catch (Exception e)
            {
                state = e.Message;
            }

            return state;
        }
    }
}
